﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExtractFiles
{
    public partial class HowToReplaceStrings : HowtoParent
    {
        private int currentPage = 1;
        private int firstPage = 2;
        private int maxPage = 7;

        public HowToReplaceStrings()
        {
            InitializeComponent();
        }

        protected override void howToSearchFilesPrevBtn_Click(object sender, EventArgs e)
        {
            if (currentPage == firstPage)
            {
                displayFirstPageControls();
            }
            else
            {
                displayNormalPageControls();
            }
            currentPage -= 1;
            displayPage();
        }

        protected override void howToSearchFilesNextBtn_Click(object sender, EventArgs e)
        {
            if (currentPage == maxPage)
            {
                displayLastPageControls();
            }
            else
            {
                displayNormalPageControls();
            }
            currentPage += 1;
            displayPage();
        }

        protected override void displayPage()
        {
            switch (currentPage)
            {
                case 1:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Select \"Replace\" tab";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringstab;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Select the \"Replace\" tab to replace particular line(s) in a file.\n\nClick \"Next\" to continue.";
                    break;
                case 2:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Browse for the file to replace";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringssrcfile;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Browse for the file where you would like to replace the content.\n\nClick \"Next\" to continue.";
                    break;
                case 3:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Set replace option - Single";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringssingleopt;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": You can set to replace just a single line one at a time for a file.\n\nClick \"Next\" to continue.";
                    break;
                case 4:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Set the original line to replace";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringsreplacestr;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Set the pattern of the line to replace. In this version of the tool, we only support exact word search, that is, only lines that contain the exact character sequence will be replaced. No wildcard or regex supported.\n\nClick \"Next\" to continue.";
                    break;
                case 5:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Set the replace string";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringswithstr;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Set the pattern that is to replace the original pattern in the file.\n\nClick \"Next\" to continue.";
                    break;
                case 6:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Set replace option - Multiple";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringsmultipleopt;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Alternatively, you may want to replace multiple patterns in a single file. Choose the \"Replace multiple\" option.\n\nClick \"Next\" to continue.";
                    break;
                case 7:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Add replace-with pattern pairs";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringsaddreplace;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Click the \"Add\" button and a dialog box will open up for you to set the original pattern and new pattern. For each pair added, it will be populated in the list box.\n\nClick \"Next\" to continue.";
                    break;
                case 8:
                    this.searchFilesStep1Label.Text = "Step " + currentPage + ": Replace now!";
                    this.selectSearchFilesTabPictureBox.Image = global::ExtractFiles.Properties.Resources.howtoreplacestringsreplacebtn;
                    this.howToSearchFilesInstructionBox.Text = "Step " + currentPage + ": Click the \"Replace\" button to replace lines in the file with the new pattern specified. The line number of each line replaced will be populated in the list box above.";
                    break;
            }
        }
    }
}
